﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sinacor.Infra.Service.Security.Services;
using Sinacor.Servico.Bovespa.Ordens.Service.ServiceContract;

namespace Sinacor.Servico.Bovespa.Ordens.Service.ServiceImplementation
{
    /// <summary>
    ///Classe de implementacao de contrato de servico Motivo
    /// </summary>
    [SinacorServiceBehavior]
    public class Motivo: IMotivo
    {
        #region Construtor

        public Motivo()
        {
        }

        #endregion

        #region IMotivo Members

        public void AlterarMotivo(Sinacor.Servico.Bovespa.Ordens.Service.DataContract.Request.MotivoRequest request)
        {
            BusinessLogic.Motivo blMotivo = new Sinacor.Servico.Bovespa.Ordens.BusinessLogic.Motivo();

            blMotivo.AlterarMotivo(Translator.DataContractToBusinessEntity.Motivo.ToMotivo(request));
        }

        public void AlterarMotivos(List<Sinacor.Servico.Bovespa.Ordens.Service.DataContract.Request.MotivoRequest> request)
        {
            BusinessLogic.Motivo blMotivo = new Sinacor.Servico.Bovespa.Ordens.BusinessLogic.Motivo();

            blMotivo.AlterarMotivos(Translator.DataContractToBusinessEntity.Motivo.ToMotivo(request));

        }

        public List<Sinacor.Servico.Bovespa.Ordens.Service.DataContract.Response.MotivoResponse> ConsultarMotivos(Sinacor.Servico.Bovespa.Ordens.Service.DataContract.Request.FiltroMotivoRequest request)
        {
            BusinessLogic.Motivo blMotivo = new Sinacor.Servico.Bovespa.Ordens.BusinessLogic.Motivo();
            
            return Translator.BusinessEntityToDataContract.Motivo.ToMotivoResponse(blMotivo.ConsultarMotivos(
                Translator.DataContractToBusinessEntity.Motivo.ToFiltroMotivo(request)));
        }

        public void ExcluirMotivo(Sinacor.Servico.Bovespa.Ordens.Service.DataContract.Request.FiltroMotivoRequest request)
        {
            BusinessLogic.Motivo blMotivo = new Sinacor.Servico.Bovespa.Ordens.BusinessLogic.Motivo();

            blMotivo.ExcluirMotivo(Translator.DataContractToBusinessEntity.Motivo.ToFiltroMotivo(request));

        }

        public void ExcluirMotivos(List<Sinacor.Servico.Bovespa.Ordens.Service.DataContract.Request.FiltroMotivoRequest> request)
        {
            BusinessLogic.Motivo blMotivo = new Sinacor.Servico.Bovespa.Ordens.BusinessLogic.Motivo();

            blMotivo.ExcluirMotivos(Translator.DataContractToBusinessEntity.Motivo.ToFiltroMotivo(request));

        }

        public void ExecutarTransacoes(List<Sinacor.Servico.Bovespa.Ordens.Service.DataContract.Request.MotivoRequest> inclusaoList, List<Sinacor.Servico.Bovespa.Ordens.Service.DataContract.Request.FiltroMotivoRequest> exclusaoList, List<Sinacor.Servico.Bovespa.Ordens.Service.DataContract.Request.MotivoRequest> alteracaoList)
        {
            BusinessLogic.Motivo blMotivo = new Sinacor.Servico.Bovespa.Ordens.BusinessLogic.Motivo();

            blMotivo.ExecutarTransacoes(Translator.DataContractToBusinessEntity.Motivo.ToMotivo(inclusaoList),
                Translator.DataContractToBusinessEntity.Motivo.ToFiltroMotivo(exclusaoList), 
                Translator.DataContractToBusinessEntity.Motivo.ToMotivo(alteracaoList));
        }

        public void IncluirMotivo(Sinacor.Servico.Bovespa.Ordens.Service.DataContract.Request.MotivoRequest request)
        {
            BusinessLogic.Motivo blMotivo = new Sinacor.Servico.Bovespa.Ordens.BusinessLogic.Motivo();

            blMotivo.IncluirMotivo(Translator.DataContractToBusinessEntity.Motivo.ToMotivo(request));

        }

        public void IncluirMotivos(List<Sinacor.Servico.Bovespa.Ordens.Service.DataContract.Request.MotivoRequest> request)
        {
            BusinessLogic.Motivo blMotivo = new Sinacor.Servico.Bovespa.Ordens.BusinessLogic.Motivo();

            blMotivo.IncluirMotivos(Translator.DataContractToBusinessEntity.Motivo.ToMotivo(request));
        }

        #endregion
    }
}
